# -*- coding: utf-8 -*-
# @Time    : 2018/12/12 9:54
import os
import sys

path = os.path.abspath(os.path.dirname(os.getcwd()))
sys.path.append(path)
from creat_bar import config
from time import sleep
from datetime import datetime
from multiprocessing import Process, Queue, Pool
keyword = config.keyword
class insertBat(object):

    def __init__(self) -> None:
        super().__init__()

    def find_mongo(self):
        # 文件夹名字要改成docid
        result = 0
        with open('../bat/del_files.bat', 'a') as af:
            while True:
                item = keyword.find_and_modify({"state":0},{'$set': {"state":1}})
                try:
                    path = item['keyword']
                except:
                    continue
                af.write('del %s'%(path))#删除文件
                if not result % 1000:
                    if result:
                        print(result)
                    else:
                        print('start')
                result += 1
if __name__ == '__main__':
    new_time_one = datetime.now()
    sleep(1.5)
    new_time = datetime.now()
    time_l = (new_time - new_time_one).seconds
    print(time_l)

    # trader = []
    # for i in range(3):
    #     pr = Process(target=insertBat().find_mongo())
    #     pr.start()
    #     trader.append(pr)
    # for i in trader:
    #     i.join()
    # print('this is %s' % (os.getpid()))